﻿using System;
using System.Collections;
using System.Windows.Controls;

namespace Algoritmos_de_Ordenação
{
    public enum ButtonClicked
    {
        Increasing,
        Decreasing,
        Random,
        Sort,
        Pause,
        Resume,
        Reset,
        Stop

    }
    public class Buttons
    {
        public static void btnIncreasing_Click(ArrayList activeSorts)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Stop();
                dreg.fillArrayOrdenado();
                dreg.desenhaBarras();
            }
        }

        public static void btnDecreasing_Click(ArrayList activeSorts)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Stop();
                dreg.fillArrayInverso();
                dreg.desenhaBarras();
            }
        }

        public static void btnRandomica_Click(ArrayList activeSorts)
        {
            int seed = unchecked((int)DateTime.Now.Ticks);
            
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Stop();
                dreg.ArraySeed = seed;
                dreg.randomica();
                dreg.desenhaBarras();
            }
        }

        public static void btnSort_Click(ArrayList activeSorts, Button[] btnsToDisable, SpeedClicked speed)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.SortSpeed = (int) speed;
                dreg.Sort();
            }

            foreach (Button b in btnsToDisable)
            {
                b.IsEnabled = false;
            }
        }

        public static void btnPausa_Click(ArrayList activeSorts)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Pausa();
            }
        }

        public static void btnResume_Click(ArrayList activeSorts)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Reinicia();
            }
        }

        public static void btnReset_Click(ArrayList activeSorts)
        {
            
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Reset();
            }
        }
        
        public static void btnStop_Click(ArrayList activeSorts, Button[] btnsToEnable)
        {
            foreach (DrawingRegion dreg in activeSorts)
            {
                dreg.Stop();
            }

            foreach (Button b in btnsToEnable)
            {
                b.IsEnabled = true;
            }
        }
    }
}
